import request from '@/utils/request'

// 获取用户信息
export function getUserInfo() {
  return request({
    url: '/api/auth/me',
    method: 'GET'
  })
}

// 更新用户信息
export interface UserInfo {
  username?: string
  avatar?: string
  nickname?: string
  gender?: number
  birthday?: string
  phone?: string
}

export function updateUserInfo(data: Partial<UserInfo>) {
  return request({
    url: '/api/auth/update',
    method: 'PUT',
    data
  })
}

// 用户登录
export interface LoginParams {
  username: string
  password: string
}

export function login(data: LoginParams) {
  return request({
    url: '/api/auth/login',
    method: 'POST',
    data
  })
}

// 用户注册
export interface RegisterParams extends LoginParams {
  nickname: string
  confirmPassword: string
}

export function register(data: RegisterParams) {
  return request({
    url: '/api/auth/register',
    method: 'POST',
    data
  })
}